package Task23;
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        while (scanner.hasNext()){
            int size = scanner.nextInt();
            int[] array = new int[size];
            for (int i = 0; i < array.length; i++) {
                array[i] = scanner.nextInt();
            }
            getValue(array,array.length);
        }
    }
    public static  int getValue(int[] gifts, int n) {
        // 出现次数
        int time = 1;
        int result = gifts[0];
        for (int i = 1; i < gifts.length; i++) {
            if(time != 0){
                if(result == gifts[i]){
                    time++;
                }else {
                    time--;
                }
            }else {
                result = gifts[i];
                time++;
            }
        }
        int len = gifts.length/2;
        int count = 0;
        for (int i = 0; i < gifts.length; i++) {
            if(gifts[i] == result){
                count++;
            }
        }
        if(count > len){
            return result;
        }
        return 0;
    }
}
